Skip to content

(GH-1529) Add whatIf support for SSHD config resources#1586

Open
Gijsreyn wants to merge 1 commit into
PowerShell:mainfrom
Gijsreyn:gh-1529/main/add-whatif-sshdconfig
Open

(GH-1529) Add whatIf support for SSHD config resources#1586
Gijsreyn wants to merge 1 commit into
PowerShell:mainfrom
Gijsreyn:gh-1529/main/add-whatif-sshdconfig

Conversation

@Gijsreyn

Copy link
Copy Markdown
Collaborator

PR Summary

Add whatIf support for SSHD config resources.

PR Context

Partially addresses #1529.

@Gijsreyn Gijsreyn force-pushed the gh-1529/main/add-whatif-sshdconfig branch from 81cb475 to 9363b57 Compare June 22, 2026 15:24
@Gijsreyn Gijsreyn force-pushed the gh-1529/main/add-whatif-sshdconfig branch from 9363b57 to dfc95ce Compare June 26, 2026 06:03
@Gijsreyn Gijsreyn marked this pull request as ready for review June 26, 2026 06:10
Copilot AI review requested due to automatic review settings June 26, 2026 06:10
@Gijsreyn Gijsreyn requested a review from tgauth June 26, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds --what-if support for the built-in OpenSSH SSHD config resources by wiring a new --what-if flag through the sshdconfig CLI, updating resource manifests to advertise what-if support, and adding Pester coverage to validate both manifest metadata and non-mutating what-if behavior.

Changes:

  • Add a --what-if flag to sshdconfig set and plumb it into set handlers to return predicted state without applying changes.
  • Update SSHD-related resource manifests to include whatIfArg and whatIfReturns.
  • Add Pester tests validating manifest what-if declarations and verifying no file/registry writes during what-if runs.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
resources/sshdconfig/tests/sshdconfig.whatif.tests.ps1 Adds Pester coverage for manifest what-if metadata and what-if “no side effects” behavior.
resources/sshdconfig/sshd-windows.dsc.resource.json Declares what-if support for the Windows global SSHD settings resource.
resources/sshdconfig/sshd-subsystemList.dsc.resource.json Declares what-if support for the SubsystemList resource.
resources/sshdconfig/sshd-subsystem.dsc.resource.json Declares what-if support for the Subsystem resource.
resources/sshdconfig/sshd_config.dsc.resource.json Declares what-if support for the sshd_config resource.
resources/sshdconfig/src/set.rs Implements what-if behavior in set paths and returns predicted state when requested.
resources/sshdconfig/src/main.rs Wires the what_if flag from CLI parsing into invoke_set.
resources/sshdconfig/src/args.rs Adds --what-if/-w flag to the set subcommand.
resources/sshdconfig/locales/en-us.toml Adds localized help text for the new what-if flag.
Comments suppressed due to low confidence (1)

resources/sshdconfig/src/set.rs:107

  • In --what-if mode, get_existing_config(cmd_info)? can indirectly seed/copy a default sshd_config via ensure_sshd_config_exists(...) (see get_existing_config implementation). That would be a side effect during what-if for repeat-keyword operations when the target config file doesn’t exist yet.
    let (keyword, entry_value) = extract_single_keyword(keyword_input.additional_properties)?;

    let mut existing_config = get_existing_config(cmd_info)?;

Comment on lines +78 to +82
let desired_state = get_default_shell_desired_state(default_shell)?;
if what_if {
default_shell_to_map(&desired_state)
} else {
set_default_shell(&desired_state)?;
Comment on lines 142 to 145

let (keyword, entries_value) = extract_single_keyword(list_input.additional_properties)?;
let mut existing_config = get_existing_config(cmd_info)?;
// Ensure it's an array
Comment on lines +298 to +302
write_and_validate_config(
&mut config_to_write,
cmd_info.metadata.filepath.as_ref(),
what_if,
)?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants